<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 2.添加路由链接 -->
        <!-- router-link  会被渲染成a链接 -->
        <!-- to 会被渲染成href属性 -->
        <!-- to的值会被渲染成hash地址 -->
        <router-link to='/user'>User</router-link>
        <router-link to='/register'>Register</router-link>
        <!-- 3.添加路由填充位（路由占位符） -->
        <router-view></router-view>
    </div>
    <!-- 1.导入vue文件 -->
    <script src="./lib/vue_2.5.22.js"></script>
    <script src="./lib/vue-router_3.0.2.js"></script>
    <script>
        // 4.定义路由组件
        const User = {
            template: `
                <h1>user 组件</h1>
            `
        }
        const Register = {
                template: `
                <h1>register 组件</h1>
            `
            }
            // 5.创建路由实例对象
        const router = new VueRouter({
            routes: [{
                path: '/user',
                component: User
            }, {
                path: '/register',
                component: Register
            }]
        })
        var vm = new Vue({
            el: '#app',
            data: {},
            //挂载路由实例对象
            router: router
        })
    </script>
</body>

</html>